package com.wgj.android.ui.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jiaai.xui.utils.http.HttpCallBack;
import com.jiaai.xui.utils.http.XHttp;
import com.jiaai.xui.utils.statusbar.XStatusBar;
import com.jiaai.xui.view.widget.XLoadingDialog;
import com.jiaai.xui.view.widget.XToast;
import com.wgj.android.R;
import com.wgj.android.http.WGJAPI;
import com.wgj.android.utils.CacheUtils;
import com.wgj.android.utils.TextViweUtils;
import com.wgj.android.utils.fonat.IconFonat;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2018/1/31.
 */

public class DonationHBActivity extends AppCompatActivity {
    @BindView(R.id.money)
    EditText money;
    @BindView(R.id.message)
    EditText message;
    @BindView(R.id.backBut)
    ImageButton backBut;
    @BindView(R.id.ti_weixin_staic)
    ImageView tiWeixinStaic;
    @BindView(R.id.tl_weixin_pay)
    RelativeLayout tlWeixinPay;
    @BindView(R.id.ti_ali_staic)
    ImageView tiAliStaic;
    @BindView(R.id.tl_ali_pay)
    RelativeLayout tlAliPay;
    @BindView(R.id.tv_qb)
    TextView tvQb;
    @BindView(R.id.ti_qb_staic)
    ImageView tiQbStaic;
    @BindView(R.id.tl_qb_pay)
    RelativeLayout tlQbPay;
    @BindView(R.id.submit)
    Button submit;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         XStatusBar.setColorNoTranslucent(this, Color.parseColor("#ff4848"));
        super.setContentView(R.layout.donation_hb_activity);
        ButterKnife.bind(this);
        TextViweUtils.setDrawableLeft(tvQb, IconFonat.Icon.icon_wallet, Color.parseColor("#f4ea2a"),8);
    }
    @OnClick({R.id.tl_weixin_pay,R.id.tl_ali_pay,R.id.tl_qb_pay})
    public void onClick(View v){
        switch (v.getId()){
            case R.id.tl_weixin_pay:
                    XToast.info("暂时无法使用");
                   /* tlWeixinPay.setBackgroundResource(R.drawable.bg_pay_mode_select);
                    tiWeixinStaic.setVisibility(View.VISIBLE);
                    tiAliStaic.setVisibility(View.GONE);
                    tlAliPay.setBackgroundResource(R.drawable.bg_pay_mode_no);*/
                break;
            case R.id.tl_ali_pay:
                XToast.info("暂时无法使用");
                break;
            case R.id.tl_qb_pay:

                break;
        }
    }
    @OnClick(R.id.submit)
    public void submit(View view) {
        if (money.getText().length() == 0) {
            XToast.error("请输入金额");
            return;
        }
        XLoadingDialog.with(this).show();
        Map<String, Object> params = new HashMap<>();
        params.put("money", money.getText().toString());
        params.put("mId", CacheUtils.getMember().getM_id());
        params.put("content", message.getText().toString());
        XHttp.obtain().post(WGJAPI.DONATIONHB_URL, params, new HttpCallBack<String>() {
            @Override
            public void onSuccess(String s) {
                XToast.success("捐赠成功", 3000);
                XLoadingDialog.with(DonationHBActivity.this).dismiss();
                //startActivity(new Intent(DonationHBActivity.this, QDActivity.class));
               // finish();
            }

            @Override
            public void onFailed(int i, String s, boolean b) {
                XToast.error("捐赠失败或余额不足请充值");
                XLoadingDialog.with(DonationHBActivity.this).dismiss();
            }
        });

    }

    @OnClick(R.id.backBut)
    public void back(View view) {
        finish();
    }
}
